<script type="text/ecmascript-6">
  import Navbar from '../components/base/navbar.vue';
  export default{
      name:"index",
      components:{
          Navbar
      },
      data(){
          return{
              page:0,
              hasMore:true,
              heights:"100%"
          }
      },
      created(){
          EventBus.$on("page-loaded",this.pageLoaded)
          this.$store.dispatch("queryCitylist");
      },
      methods:{
          jump(page,id){
              this.$router.push({name:page,params:{id:id,index:0}});
          },
          refresh(){
//              console.log(1);
              this.$store.dispatch("queryCitylist",1);
          },
          loadMore(){
              this.page=this.page+1;
              this.$store.dispatch("queryCitylist",this.page);
//              console.log(2);
          },
          pageLoaded(success,page){
            if (success) {
              this.hasMore = page.current_page < page.total_pages;
              console.log(this.hasMore);
              this.page = page.current_page;
            }
            this.$refs.pulldown.onLoadOff();
          }
      },
      computed:{
          list:{
              get(){
                  return this.$store.getters.getCityList
              }
          }
      }
  }
</script>
